import os
import glob
import pandas as pd


def merge_excel(path, on=None):
    """合并数据"""
    all_data = pd.DataFrame()
    for f in glob.glob(path):
        df = pd.read_excel(f)
        all_data = all_data.append(df, ignore_index=True)
    return all_data.drop_duplicates(on)


if __name__ == '__main__':
    print('Program is running...')
    path = r'C:\Users\chunxiao.ding\Desktop\souce'
    target_path = r'C:\Users\chunxiao.ding\Desktop\end'

    df = merge_excel(path)
    df.to_excel(os.path.join(target_path,"Total.xlsx"),index=False)
    print('Success!')

